The technology described herein relates to a method of and apparatus for encoding and decoding data, and in particular to such a method and apparatus for use to compress and decompress texture data in computer graphics systems.
It is common in computer graphics systems to generate colours for sampling positions in the image to be displayed by applying so-called textures or texture data to the surfaces to be drawn. For example, surface detail on objects may be generated by applying a predefined “texture” to a set of polygons representing the object, to give the rendered image of the object the appearance of the “texture”. Such textures are typically applied by storing an array of texture elements or “texels”, each representing given texture data (such as colour, luminance, and/or light/shadow, etc. values), and then mapping the texels onto the corresponding elements, such as (and, indeed, typically) a set of sampling positions, for the image to be displayed. The stored arrays of texture elements (data) are typically referred to as “texture maps”.
Such arrangements can provide high image quality, but have a number of drawbacks. In particular, the storage of the texture data and accessing it in use can place, e.g., high storage and bandwidth requirements on a graphics processing device (or conversely lead to a loss in performance where such requirements are not met). This is particularly significant for mobile and handheld devices that perform graphics processing, as such devices are inherently limited in their, e.g., storage, bandwidth and power resources and capabilities.
It is known therefore to try to encode such texture data in a “compressed” form so as to try to reduce, e.g., the storage and bandwidth burden that may be imposed on a device.
One known such texture data compression technique determines a set or palette of colours to be used for, e.g., a given texture map, and then stores for each texture element (texel) in the texture map an index into the set or palette of colours, indicating the colour to be used for that texel. This has the advantage that only an index, rather than a full (e.g.) colour value needs to be stored for each texel. This helps to reduce, e.g., the texture data storage requirements, but still has some drawbacks, such as in terms of reduced image quality and the necessary data processing.
Another known texture compression technique is to use so-called block truncation coding (BTC). In this technique the overall texture array (texture map) is subdivided into smaller blocks, e.g. of 4×4 texels, and a number (typically two) of base or primary colour values are determined for each such block, with each texel in the block being set to one of the base colour values. This again saves on the data that has to be stored and accessed, but at a cost of lower image quality.
U.S. Pat. No. 5,047,853 describes an improved block truncation coding technique. In this technique, two base colours are again stored for each texel block, but two additional colours to be used for the block are also derived from those two base colours (e.g. by linearly blending those colours). In this way, four colours are provided as a “palette” for the texel block, but only two colour values need to be stored for the block. Each texel in the block is then encoded using two bits, to indicate which of the four block “colours” should be used for the texel. This system provides improved image quality over basic block truncation coding, but requires more data per block.
In texture compression schemes, each encoded texture data block will typically include, inter alia, one or more integer values, representing, e.g., data values such as endpoint or base colours, to be used when determining the data value (e.g. colour) for a texture data element that the block represents. The encoded block may also include other integer values, such as index values for texture data elements that the block represents. While these integer values can be encoded in an encoded texture data block in any desired fashion, the Applicants have recognised that there is scope for improved integer value encoding and compression techniques for use when, e.g., encoding texture data for graphics processing.